﻿using System;
using System.Windows.Automation;

namespace QuickUIT.Controls
{
    public class UIDataGrid : UIBaseControl
    {
        /// <summary>
        /// Gets the total number of rows in the data grid.  
        /// If the control does not support the <see cref="GridPattern"/>, returns -1. 
        /// </summary>
        public new int RowCount
        {
            get { return base.RowCount; }
        }

        /// <summary>
        /// Specifies the total number of columns in a grid.  
        /// If the control does not support the <see cref="GridPattern"/>, returns -1. 
        /// </summary>
        public new int ColumnCount
        {
            get { return base.ColumnCount; }
        }

        /// <summary>
        /// Gets a value which indicates the primary direction of traversal for the data grid if it has a header. 
        /// If the control does not support the <see cref="TablePattern"/> , a null reference is returned.
        /// </summary>
        public new RowOrColumnMajor? RowOrColumnMajor
        {
            get { return base.RowOrColumnMajor; }
        }

        /// <summary>
        /// Gets a value which indicates if the control allows more than one child element to be selected concurrently. 
        /// </summary>
        public new bool CanSelectMultiple
        {
            get { return base.CanSelectMultiple; }
        }

        /// <summary>
        /// Gets a value which indicates if the control requires at least one child element to be selected. 
        /// </summary>
        public new bool IsSelectionRequired
        {
            get { return base.IsSelectionRequired; }
        }

        /// <summary>
        /// Gets a value which indicates whether the control can scroll horizontally. 
        /// </summary>
        public new bool HorizontallyScrollable
        {
            get { return base.HorizontallyScrollable; }
        }

        /// <summary>
        /// Gets a value which indicates whether the control can scroll horizontally. 
        /// </summary>
        public new bool VerticallyScrollable
        {
            get { return base.VerticallyScrollable; }
        }

        /// <summary>
        /// Gets the value of the horizontal scroll position.
        /// If the control does not support the <see cref="ScrollPattern"/>, returns NaN. 
        /// </summary>
        public new double HorizontalScrollPercent
        {
            get { return base.HorizontalScrollPercent; }
        }

        /// <summary>
        /// Gets the value of the vertical scroll position 
        /// If the control does not support the <see cref="ScrollPattern"/>, returns NaN.
        /// </summary>
        public new double VerticalScrollPercent
        {
            get { return base.VerticalScrollPercent; }
        }

        /// <summary>
        /// Gets the value of the horizontal size of the viewable region.
        /// If the control does not support the <see cref="ScrollPattern"/>, returns NaN.
        /// </summary>
        public new double HorizontalViewSize
        {
            get { return base.HorizontalViewSize; }
        }

        /// <summary>
        /// Gets the value of the vertical size of the viewable region.
        /// If the control does not support the <see cref="ScrollPattern"/>, returns NaN.
        /// </summary>
        public new double VerticalViewSize
        {
            get { return base.VerticalViewSize; }
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIDataGrid"/> class. 
        /// </summary>
        public UIDataGrid() : base(ControlType.DataGrid)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIDataGrid"/> class.
        /// </summary>
        /// <param name="parent">The parent of this control.</param>
        public UIDataGrid(UIBaseControl parent) : base(parent, ControlType.DataGrid)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIDataGrid"/> class.
        /// </summary>
        /// <param name="locator">The locator used to find the specific control.</param>
        public UIDataGrid(string locator) : base(null, ControlType.DataGrid, locator)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIDataGrid"/> class.
        /// </summary>
        /// <param name="parent">The parent of this control.</param>
        /// <param name="locator">The locator used to find the specific control.</param>
        public UIDataGrid(UIBaseControl parent, string locator) : base(parent, ControlType.DataGrid, locator)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIDataGrid"/> class.
        /// </summary>
        /// <param name="control">The underlying <see cref="AutomationElement"/> of the control.</param>
        public UIDataGrid(AutomationElement control) : base(control, ControlType.DataGrid)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="UIDataGrid"/> class.
        /// </summary>
        /// <param name="parent">The parent of the control</param>
        /// <param name="control">The underlying <see cref="AutomationElement"/> of the control.</param>
        public UIDataGrid(UIBaseControl parent, AutomationElement control) : base(parent, control, ControlType.DataGrid)
        {
        }

        /// <summary>
        /// Retrieves an element that represents the specified cell in the data grid. 
        /// </summary>
        /// <param name="row">The ordinal number of the row of interest.</param>
        /// <param name="col">The ordinal number of the column of interest.</param>
        /// <returns>The <see cref="AutomationElement"/> that represents the retrieved cell.</returns>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        /// <remarks>Grid coordinates are zero-based with the upper left (or upper right cell depending on locale) having coordinates (0,0).</remarks>
        public new AutomationElement GetItem(int row, int col)
        {
            return base.GetItem(row, col); 
        }

        /// <summary>
        /// Gets a collection of elements that represents all the column headers in the data grid.
        /// </summary>
        /// <returns>A collection of elements representing the column headers.</returns>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new AutomationElement[] GetColumnHeaders()
        {
            return base.GetColumnHeaders(); 
        }

        /// <summary>
        /// Gets a collection of elements that represents all the row headers in a table.
        /// </summary>
        /// <returns>A collection of elements representing the row headers.</returns>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception> 
        public new AutomationElement[] GetRowHeaders()
        {
            return base.GetRowHeaders(); 
        }

        /// <summary>
        /// Scrolls the visible region of the content area horizontally and vertically. 
        /// </summary>
        /// <param name="horizontalAmount">The horizontal scrolling increment that is specific to the control.</param>
        /// <param name="verticalAmount">The vertical scrolling increment that is specific to the control.</param>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        /// <remarks>No scroll should be passed if if the control cannot be scrolled in a given direction.</remarks>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new void Scroll(ScrollAmount horizontalAmount, ScrollAmount verticalAmount)
        {
            base.Scroll(horizontalAmount, verticalAmount);
        }

        /// <summary>
        /// Scrolls the visble region of the content area vertically by the <see cref="ScrollAmount"/>.
        /// </summary>
        /// <param name="amount">The vertical scrolling increment.</param>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new void ScrollVertically(ScrollAmount amount)
        {
            base.ScrollVertically(amount);
        }

        /// <summary>
        /// Scrolls the visble region of the content area horizontally by the <see cref="ScrollAmount"/>.
        /// </summary>
        /// <param name="amount">The horizontal scrolling increment.</param>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new void ScrollHorizontally(ScrollAmount amount)
        {
            base.ScrollHorizontally(amount);
        }

        /// <summary>
        /// Sets the horizontal and vertical scroll position as a percentage of the total content area within the data grid. 
        /// </summary>
        /// <param name="horizontalPercent">
        /// The percentage of the total horizontal content area. 
        /// <see cref="ScrollPattern.NoScroll"/> should be passed in if the data grid cannot be scrolled in this direction.
        /// </param>
        /// <param name="verticalPercent">
        /// The percentage of the total vertical content area. 
        /// <see cref="ScrollPattern.NoScroll"/> should be passed in if the data grid cannot be scrolled in this direction.
        /// </param>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new void SetScrollPercent(double horizontalPercent, double verticalPercent)
        {
            base.SetScrollPercent(horizontalPercent, verticalPercent);
        }

        /// <summary>
        /// Sets the scroll percentage to the top of the data grid.  
        /// </summary>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new void ScrollToTop()
        {
            base.ScrollToTop();
        }

        /// <summary>
        /// Gets a collection of elements that represents the current selection for the data grid. 
        /// </summary>
        /// <returns>A collection of selected elements.</returns>
        /// <exception cref="InvalidOperationException">The control pattern cannot be performed by the element.</exception>
        /// <exception cref="ElementNotAvailableException">The element is not available anymore.</exception>
        public new AutomationElement[] GetSelection()
        {
            return base.GetSelection();
        }
    }
}
